<template>
    <div class="el-mdlist">
        <div class="el-mdlist-back" >
            <span @click="backMenu">
                <img class="el-mdlist-backIcon" src="../../../../public/img/arrow.png" alt="">
                返回主页
            </span>
        </div>
        <div class="el-mdlist-title">
            <img src="../../../../public/img/materialReceiveMini.png" alt="">
            <span>物料配送</span>
        </div>
        <div class="el-mdlist-content">
            <el-menu :default-active=show class="el-menu-vertical-demo">
               
                    <el-menu-item v-for="(item,index) in listName" :key="index" :index=item.index @click="showBj(item)">
                        <template slot="title">
                            <span>{{item.name}}</span>
                        </template>
                    </el-menu-item>
          
            </el-menu>
        </div>
    </div>
</template>
<script>
export default {
    name:'MdList',
    props:{curMenus:{type:Array},
    updateCom: {
        type: Function,
        default: null
      }},
    data(){
        return{
            listName:[
                {
                    index:'1',
                    name:'配送任务',
                    url:'/materialDistribution/deliveryTask'
                }
                // ,
                // {
                //     index:'2',
                //     name:'配送扫码交接',
                //     url:'/materialDistribution/deliveryScanHandover'
                // }
                ,{
                    index:'2',
                    name:'接收直配',
                    url:'/materialDistribution/receiveDirectDistribution'
                }],
            show:''
        }
    },
    methods:{
        showBj(item){
            this.show = String(item.index);
            item.class="active";
            
            let curMenu = this.curMenus;
            let isLoad = false;
    
            for(let i=0;i< curMenu.length;i++){
                let menu = curMenu[i];
                if(menu.index == item.index){
                    menu.class="active";
                    isLoad = true;
                }else{
                    menu.class="none";
                }
            }
            if(!isLoad){
                curMenu.push(item);
            }
            
            console.log(this.curMenus);
            this.updateCom();
        },
        setShowMenu(item){
            this.show = item.index;
        },
        backMenu(){
            this.$router.push('/menu')
        }

    },
    mounted(){
        this.show = sessionStorage.getItem('listNumber')
        
    },
    beforeDestroy(){
        sessionStorage.removeItem('listNumber')
    }
}
</script>
<style scoped>
.el-mdlist {
    width: 100%;
    height: 100%;
}
.el-mdlist-back {
    width: 80%;
    margin-left: 10%;
    color: #DCEFFB;
    padding-bottom: 15px;
    border-bottom: 1px solid #FFFFFF;
    cursor: pointer;
}
.el-mdlist-backIcon {
    height: 14px;
}
.el-mdlist-title {
    color: #DCEFFB;
    padding-top: 10px;
    text-align: center;
}
.el-mdlist-title span {
    vertical-align: 45%;
}
.el-menu {
    background-color: transparent;
    border: none;
}
.el-mdlist-content {
    margin-top: 15px;
    text-align: center;
}
.el-menu-item {
    padding-top: 10px;
    padding-bottom: 10px;
    height: 40px;
    line-height: 20px;
    color: #DCEFFB;
}
.el-menu-item:hover {
    background-color: #2BBECF;
}
.el-menu-item.is-active {
    background-color: #2BBECF;
    color: #FFFFFF;
}
</style>